import express, { json } from 'express';
const app = express();
app.use(json()); // 解析json格式的请求体

app.get('/:page', function (req, res) {
    const {page} = req.params
    const list1 = [];
    for (let i = 0; i < 10; i++) {
        list1.push({
            id: i,
            name: i + "xx"
        })
    }
    const list2 = [];

    for (let i = 10; i < 20; i++) {
        list2.push({
            id: i,
            name: i + "xx"
        })
    }
    res.json({
        total: 20,
        list: page==1?list1:list2
    })
})  

app.listen(3001, () => {
    console.log(`Server is running on http://localhost:${3000}`);
  });